<?php
	include "public/commom/config.php";//引入配置连接数据库文件
	include "public/commom/thumb.php";//引入缩略图文件
	include "public/commom/commom.php";//引入配置图片文件
	
	$user_id = $_SESSION["user_id"];
	
	$sql = "SELECT * FROM user WHERE id = '$user_id'";//sql语句 - 查找该账号记录
	
	$result = mysqli_query($conn, $sql);//result - 执行sql语句
	
	while($row = mysqli_fetch_array($result)) {//循环
		$username = $row["username"];//昵称
		$mobilephone = $row["mobilephone"];//手机号码
		$email = $row["email"];//邮箱
		$gender = $row["gender"];//性别
		$headportrait = $row["headportrait"];//头像
		$briefintroduction = $row["briefintroduction"];//个人简介
	}
	
	mysqli_close($conn);//关闭数据库连接
?>

<!DOCTYPE HTML>
<html lang="zh-CN">
<head>
	<meta charset="UTF-8"/>
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
	<meta name="renderer" content="webkit">
	<title>完善用户资料</title>
	<!--[if lt IE 9]>
      <script src="//cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="//cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
	<script type="text/javascript" src="js/jquery-1.11.3.min.js" ></script>
	<script type="text/javascript" src="js/bootstrap.min.js"></script>
	<link rel="stylesheet" href="css/bootstrap.min.css" />
	<link rel="stylesheet" href="css/set.css" />
</head>
<body>

<!-- 导航条 -->

<div class="container">
	<div class="row userset">
		<div class="col-md-8 col-md-offset-2 cont">
			<form role="form" action="personal.php" method="post" enctype="multipart/form-data">
				<div class="row">
					<div class="col-md-7">
						<div class="form-group">
							<label>昵称：</label>
							<input type="text" name="username" class="form-control" value="<?php echo $username; ?>" placeholder="昵称" autocomplete="off">
						</div>
						<div class="form-group">
							<label>手机号码：</label>
							<input type="text" name="mobilephone" class="form-control" value="<?php echo $mobilephone; ?>" placeholder="手机号码" autocomplete="off">
						</div>
						<div class="form-group">
							<label>邮箱：</label>
							<input type="text" name="email" class="form-control" value="<?php echo $email; ?>" placeholder="邮箱" autocomplete="off">
						</div>
							<label>性别：</label>
						<?php
							switch($gender) {
								case "0";
									
									echo "<label class='radio-inline'>
											<input type='radio' name='gender' value='0' checked> 帅哥
										</label>
										<label class='radio-inline'>
											<input type='radio' name='gender' value='1'> 美女
										</label>";
										
								break;
								
								case "1";
									
									echo "<label class='radio-inline'>
											<input type='radio' name='gender' value='0'> 帅哥
										</label>
										<label class='radio-inline'>
											<input type='radio' name='gender' value='1' checked> 美女
										</label>";
										
								break;
								
								default:
									echo "<label class='radio-inline'>
											<input type='radio' name='gender' value='0'> 帅哥
										</label>
										<label class='radio-inline'>
											<input type='radio' name='gender' value='1'> 美女
										</label>";
							}
						?>
					</div><!-- top_left -->
					<div  class="col-md-5">
						<div class="form-group">
							<div class="col-md-12">
								<label>头像：</label>
							</div>
							<div class="col-md-8 col-md-offset-2">
								<img class="img-circle" src="<?php echo $imgPath . $headportrait; ?>" width="100%"/>
								<input type="file" name="headportrait" accept="image/gif, image/jpeg, image/png, image/jpg, image/webp">
							</div>
						</div>
					</div><!-- top_right -->
				</div>
				<div class="form-group">
					<label>个人简介：</label>
					<textarea name="briefintroduction" class="form-control" rows="4" placeholder="个人简介"><?php echo $briefintroduction; ?></textarea>
				</div><!-- but -->
	
				<div class="row">
					<div class="col-md-3 col-md-offset-6">
						<a href="index.php" class="btn btn-default btn-block">返&nbsp;&nbsp;回</a>
					</div>
					<div class="col-md-3">
						<input type="hidden" name="headportrait" value="<?php echo $headportrait; ?>" />
						<input type="hidden" name="user_id" value="<?php echo $user_id; ?>" />
						<input type="submit" class="btn btn-primary btn-block" value="保存">
					</div>
				</div>
			</form>
			
		</div>
	</div>
</div>

</body>
</html>
